<html><body bgcolor="#000000" text="#ffffff"><table><tr><td colspan="2"><h3>Problem Statement</h3></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><p>
John and Brus have become very famous people all over the world, especially in Bolivia.
Stories written about them by a Bolivian man have become very popular in that country.
John and Brus have decided to visit their fans in Bolivia, but unfortunately, they only have time to visit one city each.
</p>

<p>
John will randomly choose one city.
Each city has the same probability of being chosen.
If he chooses the i-th city, he will meet between <b>minJ</b>[i] and <b>maxJ</b>[i] fans, inclusive.
Each possible number of fans is equally likely.
Brus will go through the exact same process, but in his case, the number of fans he would meet in the i-th city is between <b>minB</b>[i] and <b>maxB</b>[i], inclusive.
Note that John and Brus are not required to visit different cities.
Return the probability that John and Brus will each meet the same number of fans.
</p>
</td></tr><tr><td colspan="2"><h3>Definition</h3></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td>Class:</td><td>TheFansAndMeetingsDivTwo</td></tr><tr><td>Method:</td><td>find</td></tr><tr><td>Parameters:</td><td>vector &lt;int&gt;, vector &lt;int&gt;, vector &lt;int&gt;, vector &lt;int&gt;</td></tr><tr><td>Returns:</td><td>double</td></tr><tr><td>Method signature:</td><td>double find(vector &lt;int&gt; minJ, vector &lt;int&gt; maxJ, vector &lt;int&gt; minB, vector &lt;int&gt; maxB)</td></tr><tr><td colspan="2">(be sure your method is public)</td></tr></table></td></tr><tr><td>&#160;&#160;&#160;&#160;</td></tr><tr><td></td></tr><tr><td colspan="2"><h3>Notes</h3></td></tr><tr><td align="center" valign="top">-</td><td>The returned value must be accurate to within a relative or absolute value of 1E-9.</td></tr><tr><td colspan="2"><h3>Constraints</h3></td></tr><tr><td align="center" valign="top">-</td><td><b>minJ</b> will contain between 1 and 50 elements, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td><b>minJ</b>, <b>maxJ</b>, <b>minB</b> and <b>maxB</b> will contain the same number of elements.</td></tr><tr><td align="center" valign="top">-</td><td>Each element of <b>minJ</b>, <b>maxJ</b>, <b>minB</b> and <b>maxB</b> will be between 1 and 50, inclusive.</td></tr><tr><td align="center" valign="top">-</td><td>The i-th element of <b>minJ</b> will be less than or equal to the i-th element of <b>maxJ</b>.</td></tr><tr><td align="center" valign="top">-</td><td>The i-th element of <b>minB</b> will be less than or equal to the i-th element of <b>maxB</b>.</td></tr><tr><td colspan="2"><h3>Examples</h3></td></tr><tr><td align="center" nowrap="true">0)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{1}</pre></td></tr><tr><td><pre>{3}</pre></td></tr><tr><td><pre>{1}</pre></td></tr><tr><td><pre>{1}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 0.3333333333333333</pre></td></tr><tr><td><table><tr><td colspan="2">Brus will definitely meet one fan, and the probability of John meeting one fan as well is 1/3.
</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">1)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{5, 7, 7, 1, 6, 1, 1}</pre></td></tr><tr><td><pre>{8, 9, 7, 3, 9, 5, 3}</pre></td></tr><tr><td><pre>{9, 12, 10, 14, 50, 9, 10}</pre></td></tr><tr><td><pre>{9, 13, 50, 15, 50, 12, 11}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 0.014880952380952378</pre></td></tr><tr><td><table><tr><td colspan="2">The only possible same number of fans that John and Brus can meet is 9. In order for them to meet 9 fans, John must visit city 1 or city 4 and Brus must visit city 0 or city 5.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">2)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{44}</pre></td></tr><tr><td><pre>{47}</pre></td></tr><tr><td><pre>{4}</pre></td></tr><tr><td><pre>{7}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 0.0</pre></td></tr><tr><td><table><tr><td colspan="2">No chance to meet the same number of fans.</td></tr></table></td></tr></table></td></tr><tr><td align="center" nowrap="true">3)</td><td></td></tr><tr><td>&#160;&#160;&#160;&#160;</td><td><table><tr><td><table><tr><td><pre>{1, 6, 3, 1, 4, 3, 5, 1}</pre></td></tr><tr><td><pre>{7, 8, 5, 7, 9, 7, 9, 3}</pre></td></tr><tr><td><pre>{5, 1, 5, 3, 1, 2, 4, 1}</pre></td></tr><tr><td><pre>{9, 2, 7, 9, 4, 5, 4, 9}</pre></td></tr></table></td></tr><tr><td><pre>Returns: 0.11562305130385474</pre></td></tr><tr><td></td></tr></table></td></tr></table><p>This problem statement is the exclusive and proprietary property of TopCoder, Inc.  Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited.  (c)2003, TopCoder, Inc.  All rights reserved.  </p></body></html>
